-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate Spree::Payment
offsets
#5008
Deprecate Spree::Payment
offsets
#5008
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of questions to better understand if we have alternatives. Thanks!
66b3652
to
83f1dc6
Compare
Spree::Payment#offsets
Spree::Payment
offsets
83f1dc6
to
32f5fae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left another small note for our future selves, but I'm also ok as is.
@@ -101,7 +111,10 @@ def offsets_total | |||
# @return [BigDecimal] the amount of this payment minus the offsets | |||
# (old-style refunds) and refunds | |||
def credit_allowed | |||
amount - (offsets_total.abs + refunds.sum(:amount)) | |||
amount - ( | |||
(self.class.where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed' AND source_id = ?", id).sum(:amount)).abs + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, maybe a variable makes sense? We could add a comment to easily recall which part of the method we need to remove when offset_payment
will be gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that I needed to repeat the inline on Spree::Order#has_non_reimbursement_related_refunds?
, and that the code should really be very short-lived (we should remove it in #4989), I'd prefer to keep it simple if you think it's ok 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same suggestion as alberto, but also fine with this give its expected short life
The old system for refunds was removed in 2014 [1]. We deprecate the `.offset_payment` scope, which is in turn used by the `.offsets` association. We inline its usage on a couple of methods until we perform the full removal. [1] - spree/spree#4883
32f5fae
to
03ae9a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
@@ -101,7 +111,10 @@ def offsets_total | |||
# @return [BigDecimal] the amount of this payment minus the offsets | |||
# (old-style refunds) and refunds | |||
def credit_allowed | |||
amount - (offsets_total.abs + refunds.sum(:amount)) | |||
amount - ( | |||
(self.class.where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed' AND source_id = ?", id).sum(:amount)).abs + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same suggestion as alberto, but also fine with this give its expected short life
This was a leftover for a feature that has been removed long time ago. Please use Refunds now. Ref solidusio#5008
This was a leftover for a feature that has been removed long time ago. Please use Refunds now. Ref solidusio#5008
This was a leftover for a feature that has been removed long time ago. Please use Refunds now. Ref solidusio#5008
This was a leftover for a feature that has been removed long time ago. Please use Refunds now. Ref solidusio#5008
This was a leftover for a feature that has been removed long time ago. Please use Refunds now. Ref solidusio#5008
Summary
The old system for refunds was removed in 2014.
We deprecate the
.offset_payment
scope, which is in turn used by the.offsets
association. We inline its usage on a couple of methods until we perform the full removal.Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: